package com.atguigu.spzx.manager.handler;

import com.atguigu.spzx.manager.service.OrderStatisticsService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.joda.time.DateTime;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author LT
 * @create 2024-03-20-16:34
 */
@Component
@Slf4j
public class SpzxTask {

    @Resource
    OrderStatisticsService orderStatisticsService;


    @Scheduled(cron = "0 0 2 * * ?" )
    public void generateOrderStatistics(){

        String lastDate = new DateTime().minusDays(1).toString("yyyy-MM-dd");
        orderStatisticsService.generateOrderStatistics(lastDate);
        log.info("定时任务执行了:{}" , new DateTime().toString("yyyy-MM-dd HH:mm:ss"));
    }


}
